package com.example.demo.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;
/**
 * keyongjin
 * 2021-08-08
 * */
@Service
public class DConvertLService {

	private Map<Integer, String[]> map = null;

	public DConvertLService() {
		map = new HashMap();
		map.put(0, new String[] { "" });
		map.put(1, new String[] { "" });
		map.put(2, new String[] { "a", "b", "c" });
		map.put(3, new String[] { "d", "e", "f" });
		map.put(4, new String[] { "g", "h", "i" });
		map.put(5, new String[] { "j", "k", "l" });
		map.put(6, new String[] { "m", "n", "o" });
		map.put(7, new String[] { "p", "q", "r", "s" });
		map.put(8, new String[] { "t", "u", "v" });
		map.put(9, new String[] { "w", "x", "y", "z" });

	}
	/**
	 * 参数pin:输入的值
	 * 功能：根据输入值求九宫格的字符组合
	 * */
	public String DconvertL(int pin) {
		String result = "";
		if (pin >= 0 && pin <= 9) {
			String temp[] = map.get(pin);
			for (String sub : temp) {
				result += " " + sub;
			}
		} else if (pin > 9 && pin <= 99) {
			int shiWei = pin % 100 / 10;
			int geWei = pin % 10;
			String[] shitemp = map.get(shiWei);
			String[] getemp = map.get(geWei);
			for (String ge : getemp) {
				for (String shi : shitemp) {
					result += " " + ge + shi;
				}
			}
		}
		return result;
	}
}
